<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
	href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css">
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script
	src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>

</head>
<body>
	<%
		Connection con = null;
		try {
			request.setCharacterEncoding("utf-8");
			Class.forName("com.mysql.jdbc.Driver");
			String url = "jdbc:mysql://192.168.0.2:3306/namecard";
			String sql = "INSERT INTO introduce(name, age, tel, gender, addr) values(?, ?, ?, ?, ?)";
			con = DriverManager.getConnection(url, "elo123123",
					"alflso!@34");
			PreparedStatement ps = con.prepareStatement(sql);
			ps.setString(1, request.getParameter("name"));
			ps.setString(2, request.getParameter("age"));
			ps.setString(3, request.getParameter("tel"));
			ps.setString(4, request.getParameter("gender"));
			ps.setString(5, request.getParameter("addr"));
			//
			con.setAutoCommit(false);
			ps.executeUpdate();
			con.commit();
			response.sendRedirect("Research.jsp");

		} catch (Exception exc) {
			exc.printStackTrace();
			try {
				con.rollback();
			} catch (SQLException ec) {
				ec.printStackTrace();
			}
		} finally {
			try {
				con.setAutoCommit(true);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	%>
</body>
</html>